package com.excilys.converter;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Component;

import com.excilys.dto.AccountDTO;
import com.excilys.model.Account;

/**
 * Converter that allows to switch from the original Account model to the AccountDTO model
 * 
 * @author excilys dev: GF
 * 
 */

@Component
public class AccountToAccountDTOConverter {

	public AccountDTO convertAccount(Account account) {

		AccountDTO accountDTO = new AccountDTO();

		accountDTO.setAccountDTOAmount(account.getAccountAmount());
		accountDTO.setAccountDTOName(account.getAccountName());
		accountDTO.setAccountDTOType(account.getAccountType());

		return accountDTO;
	}

	public List<AccountDTO> convertAccountList(List<Account> accountList) {

		List<AccountDTO> accountDtoList = new ArrayList<AccountDTO>();

		for (Account account : accountList) {
			AccountDTO accountDto = new AccountDTO();
			accountDto = convertAccount(account);
			accountDtoList.add(accountDto);
		}

		return accountDtoList;
	}

}
